import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

public class SimpleTest {

    @Test
    public void test3() {
        SimpleDateFormat myFmt=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
        SimpleDateFormat myFmt1=new SimpleDateFormat("yy/MM/dd HH:mm");
        SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//等价于now.toLocaleString()
        SimpleDateFormat myFmt3=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒 E ");
        SimpleDateFormat myFmt4=new SimpleDateFormat(
                "一年中的第 D 天 一年中第w个星期 一月中第W个星期 在一天中k时 z时区");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//        DateTime parse = DateUtil.parse(simpleDateFormat.format(new Date()));
        String time = new Date().getTime()+"";
        String substring = time.substring(0, 8);
        System.out.println(substring);
        //检查参数 为空抛出空指针异常
        Objects.requireNonNull("xx");

        String a = "helloword";
        String b = "hello" + new String("word");
        String c = "hello" + "word";
        String d = new String("helloword");
        System.out.println(a == b);

        System.out.println(a.equals(b));
        System.out.println(a == c);
        System.out.println(a.equals(c));

        System.out.println(a == d);
        System.out.println(b == d);
        //json转义
//        String s = StringEscapeUtils.unescapeJavaScript(data.get(0).toString());
//        JSONUtil.parseArray()
    }

    //    34 获取用键盘输入常用的的两种方法
//    public static void main(String[] args) throws IOException {
//        Scanner input = new Scanner(System.in);
//        String s = input.nextLine();
//
//        System.out.println(s);
//
//        BufferedReader input2 = new BufferedReader(new InputStreamReader(System.in));
//        String s2 = input2.readLine();
//        System.out.println(s2);
//
//        input2.close();
//        input.close();
//    }
    @Test
    public void test() {

        boolean a = true;
        boolean b = true;
        if(a && b){
            System.out.println(1);
        }

        String cc="1,2";
        //char 为单引号
        String[] strings2 = StrUtil.splitToArray( cc, ',');
        String join1 = ArrayUtil.join(strings2, ",");
        System.out.println(join1);

        List<String> strings1 = Arrays.asList(strings2);
        System.out.println(strings1);

        List<Long> collect = strings1.stream().map(x -> {
            return Long.valueOf(x);
        }).collect(Collectors.toList());
        System.out.println(collect);

    }


    /**
     *  接口和抽象类
     */
    abstract class  abs{
        int a = 1;
        void c(){
            System.out.println(a);
        }
    }
    interface aaa{
        static final int a1=1;
        int b=1;//默认 static final
        abstract  void  c1();
    }

    class dd extends abs implements aaa{
        @Override
        public void c1() {
            this.a=2;
        }
    }


    /**
     * list  set
     * @param args
     */
    public static void main(String[] args) {
        //uuid
        System.out.println(IdUtil.randomUUID());
        //雪花算法id 64 bit 的long类型
        System.out.println(IdUtil.getSnowflake(0,0).nextId());
        List  a = new ArrayList(Arrays.asList("1","2"));
        Iterator iterator = a.iterator();
        if(iterator.hasNext()){
            iterator.next();
        }
        a.get(1);
        a.add(1);
        a.add(1);//可以插入重复的数据
        System.out.println(a);

        Set b = new HashSet(Arrays.asList("1","2",1));
        b.iterator();
        b.add("1");
        b.add(1);//插不入重复的数据 比较重复是比较hashcode 然后hashcode重复的情况下equals
        b.add(1);
        System.out.println(b);
    }

}
